﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using SYcwpb.Models;
using System.Collections.Specialized;


namespace SYcwpb.ViewModels.DataProvider
{
    public class BedRoomObjects:ObservableCollection<BedRoomObject>
    {
        public event ItemEndEditEventHandler itemEndEdit;

        protected override void InsertItem(int index, BedRoomObject item)
        {
            base.InsertItem(index, item);

            item.ItemEndEdit += new ItemEndEditEventHandler(item_ItemEndEdit);
        }

        void item_ItemEndEdit(IEditableObject sender)
        {
            if (itemEndEdit != null)
            {
                itemEndEdit(sender);
            }
        }

        public void UpdateCollection()
        {
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(
                            NotifyCollectionChangedAction.Reset));
        }
    }

    public class BedRoomObject:IEditableObject,INotifyPropertyChanged
    {
        public const string CANCELED = "已取消";
        public const string CANCEL_CALL = "取消叫醒";
        public event ItemEndEditEventHandler ItemEndEdit;

        public void BeginEdit() { }

        public void CancelEdit() { }

        public void EndEdit()
        {
            if (ItemEndEdit != null)
                ItemEndEdit(this);
        }

        private string _roomName;
        public string RoomName
        {
            get { return _roomName; }
            set
            {
                if (value == _roomName)
                    return;

                _roomName = value;

                OnPropertyChanged("RoomName");
            }
        }

        private string _roomType;
        public string RoomType
        {
            get { return _roomType; }
            set
            {
                if (value == _roomType)
                    return;

                _roomType = value;

                OnPropertyChanged("RoomType");
            }
        }

        private string _canCelCall;
        public string CanCelCall
        {
            get { return _canCelCall; }
            set
            {
                _canCelCall = value;
                OnPropertyChanged("CanCelCall");
            }
        }


        private string _bedIndex;
        public string BedIndex
        {
            get { return _bedIndex; }
            set
            {
                if (value == _bedIndex)
                    return;

                _bedIndex = value;

                OnPropertyChanged("BedIndex");
            }
        }

        private YBDriver _theDriver;
        public YBDriver TheDriver
        {
            get { return _theDriver; }
            set
            {
                if (value == _theDriver)
                    return;

                _theDriver = value;

                OnPropertyChanged("TheDriver");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (null != handler)
            {
                var e = new PropertyChangedEventArgs(propertyName);
                handler(this, e);
            }

        }
    }

    public class YBDriver
    {
        public string DriverName { get; set; }

        public string Sex { get; set; }

        public DateTime DTCallTime
        {
            get { return DateTime.Parse(CallTime); }
            set
            {
                CallTime = ((DateTime)value).ToString("HH:mm:ss");
            }
        }

        public string DutyTime { get; set; }

        public string CallTime { get; set; }

        public string driverCommandID { get; set; }

        public int driverTotal { get; set; }

        public bool IshasRoom { get; set; }
    }

    /// <summary>
    /// 房间
    /// </summary>
   public class DriverRoom
    {
       // public string br_name { get; set; }
        public string ID{get;set;}
        public string br_name{get;set;}
        public int br_bed_num{get;set;}
       /// <summary>
       /// 已被占用人数
       /// </summary>
        public int br_bed_avai{get;set;}
        public string br_sex{get;set;}
        public string br_line{get;set;}
        public string br_priority{get;set;}
        public string br_phoneno { get; set; }
        public List<RoomBed> beds { get; set; }
        public List<string> ListDriverComand { get; set; }
        public Queue<int> CombineListIndex;
        public DriverRoom()
        {
            br_bed_num = 0;
            beds = new List<RoomBed>();
            ListDriverComand = new List<string>();
            CombineListIndex = new Queue<int>();
        }
    }

   public class RoomBed
   {
       
      /// <summary>
      /// 床号
      /// </summary>
       public string br_bed_num { get; set; }
      
       //public List<BedRoomObject> beds { get; set; }
   }
}
